<template>
  <div class="page-box">
    <el-card class="page-box-card">
      <el-form :model="queryParams" ref="queryForm" size="small" label-width="88px" inline>
        <el-form-item label="所属项目" prop="param.projectId">
          <!-- <el-select
            style="width: 240px"
            v-model="queryParams.param.projectId"
            placeholder="请选择所属项目"
          >
            <el-option label="项目一" value="1"> </el-option>
            <el-option label="项目二" value="2"> </el-option>
          </el-select> -->
          <el-select style="width: 240px" clearable v-model="queryParams.param.projectId" placeholder="请选择所属项目">
            <el-option v-for="item in projectList" :key="item.id" :label="item.topicShortName" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="课题名称" prop="param.name">
          <el-input v-model="queryParams.param.name" placeholder="请输入课题名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
            v-hasPermi="['definition:class:add']">新增</el-button>
        </el-col>
        <!-- <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleEdit"
            v-hasPermi="['definition:class:edit']"
            >修改</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['definition:class:delete']"
            >删除</el-button
          >
        </el-col> -->
        <!-- <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            v-hasPermi="['definition:class:download']"
            @click="downloadData"
            >导出</el-button
          >
        </el-col> -->
      </el-row>
      <el-table v-loading="loading" :data="dataList" style="width: 100%" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" fixed />
        <el-table-column type="index" label="序号" width="55" align="center" fixed />
        <el-table-column prop="projectName" label="所属项目" align="center" width="200">
        </el-table-column>
        <el-table-column prop="name" label="课题名称" align="center" width="200">
        </el-table-column>
        <el-table-column prop="education" label="课题描述" align="center">
        </el-table-column>
        <el-table-column prop="createBy" label="创建人" align="center" width="200">
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" align="center" width="200">
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right" width="340">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)"
              v-hasPermi="['system:dept:edit']">修改</el-button>
            <el-button size="mini" type="text" style="color: red" icon="el-icon-delete" @click="handleDelete(scope.row)"
              v-hasPermi="['system:dept:edit']">删除</el-button>
            <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetails(scope.row)"
              v-hasPermi="['system:dept:edit']">详情</el-button>
            <el-button size="mini" type="text" icon="el-icon-view" @click="handleCondition(scope.row)"
              v-hasPermi="['system:dept:edit']">入组条件</el-button>
            <!-- <el-button size="mini" type="text" icon="el-icon-view" @click="handleStudy(scope.row)"
              v-hasPermi="['system:dept:edit']">科研路径</el-button> -->
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </el-card>
    <!-- 添加或修改对话框 -->
    <el-dialog :title="title" :visible.sync="addDialog" width="800px" append-to-body>
      <el-form ref="topic" :model="addForm" :rules="topicRules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="所属项目" prop="projectId">
              <!-- <el-select
                style="width: 240px"
                v-model="addForm.projectId"
                placeholder="请选择所属项目"
              >
                <el-option label="项目一" value="项目一"> </el-option>
                <el-option label="项目二" value="项目二"> </el-option>
              </el-select> -->
              <el-select style="width: 240px" clearable v-model="addForm.projectId" placeholder="请选择所属项目">
                <el-option v-for="item in projectList" :key="item.id" :label="item.topicShortName" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="课题名称" prop="name">
              <el-input v-model="addForm.name" placeholder="请输入课题名称"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="课题描述" prop="education">
              <el-input type="textarea" :rows="4" v-model="addForm.education" placeholder="请输入课题描述"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 设置入组条件 -->
    <el-dialog title="设置入组条件" :visible.sync="conditionDialog" width="800px" append-to-body>
      <el-form ref="form" :model="conditionData" :rules="conditionDataRules" label-width="120px">
        <div class="title">人口学信息</div>
        <el-row>
          <el-col :span="12" v-if="conditionData.gender !== null">
            <el-form-item label="性别" prop="gender">
              <el-radio-group v-model="conditionData.gender">
                <el-radio v-for="dict in dict.type.sys_user_sex" :key="dict.value"
                  :label="dict.value - 0">{{ dict.label }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.age !== null">
            <el-form-item label="年龄段" prop="age">
              <el-radio-group v-model="conditionData.age">
                <el-select style="width: 240px" v-model="conditionData.age" placeholder="请选择所年龄段">
                  <el-option label="0~9岁" value="1"> </el-option>
                  <el-option label="10~19岁" value="2"> </el-option>
                  <el-option label="20~29岁" value="3"> </el-option>
                  <el-option label="30~39岁" value="4"> </el-option>
                  <el-option label="40~49岁" value="5"> </el-option>
                  <el-option label="50~59岁" value="6"> </el-option>
                  <el-option label="60~69岁" value="7"> </el-option>
                  <el-option label="70~79岁" value="8"> </el-option>
                  <el-option label="80~89岁" value="9"> </el-option>
                  <el-option label="90~99岁" value="10"> </el-option>
                </el-select>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.education !== null">
            <el-form-item label="受教育程度" prop="education">
              <el-radio-group v-model="conditionData.education">
                <el-select style="width: 240px" v-model="conditionData.education" placeholder="请选择受教育程度">
                  <el-option v-for="(item, index) in educationOptions" :key="index" :label="item.label"
                    :value="item.value - 0">
                  </el-option>
                </el-select>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.job !== null">
            <el-form-item label="职业" prop="job">
              <el-radio-group v-model="conditionData.job">
                <el-select style="width: 240px" v-model="conditionData.job" placeholder="请选择">
                  <el-option v-for="(item, index) in careerOptions" :key="index" :label="item.label"
                    :value="item.value - 0">
                  </el-option>
                </el-select>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.area !== null">
            <el-form-item label="地区" prop="area">
              <el-cascader v-model="conditionData.area" style="width: 100%" :options="areaData" :props="areaProps"
                clearable></el-cascader>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="title" v-if="conditionData.treatmentTypes && conditionData.treatmentTypes.length">治疗类型</div>
        <el-row>
          <el-col :span="24" v-if="conditionData.treatmentTypes && conditionData.treatmentTypes.length">
            <el-form-item label="治疗类型" prop="treatmentTypes">
              <el-select style="width: 100%" v-model="conditionData.treatmentTypes" placeholder="请选择治疗类型" multiple
                clearable>
                <el-option v-for="(item, index) in typesOptions" :key="index" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="title" v-if="conditionData.zdbm && conditionData.zdbm.length || conditionData.ssbm && conditionData.ssbm.length">出院诊断</div>
        <el-row>
          <el-col :span="24" v-if="conditionData.zdbm && conditionData.zdbm.length">
            <el-form-item label="诊断编码" prop="zdbm">
              <el-select style="width: 240px" v-model="conditionData.zdbm" placeholder="请选择诊断编码" multiple clearable>
                <el-option label="脑卒中，未特指为出血或梗死" value="I64">
                </el-option>
                <el-option label="入脑前动脉的闭塞或狭窄，未造成脑梗死" value="I65">
                </el-option>
                <el-option label="大脑动脉的闭塞和狭窄，未造成脑梗死" value="I66">
                </el-option>
                <el-option label="其它脑血管病、急性动脉瘤" value="I67">
                </el-option>
                <el-option label="分类于他处的疾病引起的脑血管疾患" value="I68">
                </el-option>
                <el-option label="中高危风险患者预防静脉血栓栓塞" value="I82.900x004">
                </el-option>
                <el-option label="脑梗死" value="I63"> </el-option>
                <el-option label="短暂性脑缺血发作（TIA）" value="G45.900x001">
                </el-option>
                <el-option label="脑内出血" value="I61"> </el-option>
                <el-option label="蛛网膜下腔出血" value="I60"> </el-option>
                <el-option label="大脑静脉血栓形成引起的脑梗死，非生脓性" value="I63.600">
                </el-option>
                <el-option label="化脓性海绵窦血栓形成" value="G08.x00x006">
                </el-option>
                <el-option label="产褥期大脑静脉窦血栓形成" value="O87.301">
                </el-option>
                <el-option label="化脓性乙状窦血栓形成" value="G08.x00x003">
                </el-option>
                <el-option label="化脓性横窦血栓形成" value="G08.x00x009">
                </el-option>
                <el-option label="侧窦栓塞" value="G08.x00x010"> </el-option>
                <el-option label="椎-基底动脉盗血综合征" value="G45.003">
                </el-option>
                <el-option label="锁骨下动脉盗血综合征" value="G45.801">
                </el-option>
                <el-option label="颈内动脉供血不足" value="G45.101">
                </el-option>
                <el-option label="颈动脉闭塞综合征" value="G45.102">
                </el-option>
                <el-option label="脑淀粉样脑血管病（CAA）" value="E85.400x027">
                </el-option>
                <el-option label="脑血管畸形" value="Q28.300x001"> </el-option>
                <el-option label="伴皮层下梗死和白质脑病的常隐性脑动脉病（CARASIL）" value="I67.8">
                </el-option>
                <el-option label="伴皮层下梗死和白质脑病的常染色体显性遗传性脑动脉病(CADASIL)" value="I67.800x012">
                </el-option>
                <el-option label="法布里病（FabryDisease）" value="E75.200x023 E75.205">
                </el-option>
                <el-option label="线粒体脑肌病伴高乳酸血症和卒中样发作综合征（MELAS）" value="G71.300x001">
                </el-option>
                <el-option label="血管性痴呆" value="F01.900"> </el-option>
                <el-option label="皮层下血管性痴呆" value="F01.200">
                </el-option>
                <el-option label="混合型皮层和皮层下血管性痴呆" value="F01.300">
                </el-option>
                <el-option label="血管性痴呆，其他的" value="F01.800">
                </el-option>
                <el-option label="出血性痴呆" value="F01.800x001"> </el-option>
                <el-option label="初发性或维持性睡眠障碍［失眠症］" value="G47.000">
                </el-option>
                <el-option label="日节律性睡眠障碍" value="G47.200x003">
                </el-option>
                <el-option label="睡眠障碍,其他的" value="G47.800"> </el-option>
                <el-option label="睡眠障碍" value="G47.900"> </el-option>
                <el-option label="血管性帕金森综合征" value="G21.400">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24" v-if="conditionData.ssbm && conditionData.ssbm.length">
            <el-form-item label="手术编码" prop="ssbm">
              <el-cascader v-model="conditionData.ssbm" style="width: 100%" :options="options" :props="props"
                :show-all-levels="false"></el-cascader>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="title" v-if="conditionData.jyy !== null || conditionData.kny !== null || conditionData.jty !== null || conditionData.kxxby !== null || conditionData.tzy !== null || conditionData.kxgjly !== null || conditionData.zyzl !== null || conditionData.other !== null">出院用药</div>
        <el-row>
          <el-col :span="12" v-if="conditionData.jyy !== null">
            <el-form-item label="降压药" prop="jyy">
              <el-radio-group v-model="conditionData.jyy">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.kny !== null">
            <el-form-item label="抗凝药" prop="kny">
              <el-radio-group v-model="conditionData.kny">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.jty !== null">
            <el-form-item label="降糖药" prop="jty">
              <el-radio-group v-model="conditionData.jty">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.kxxby !== null">
            <el-form-item label="抗血小板药" prop="kxxby">
              <el-radio-group v-model="conditionData.kxxby">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.tzy !== null">
            <el-form-item label="调脂药" prop="tzy">
              <el-radio-group v-model="conditionData.tzy">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.kxgjly !== null">
            <el-form-item label="抗血管痉挛药" prop="kxgjly">
              <el-radio-group v-model="conditionData.kxgjly">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.zyzl !== null">
            <el-form-item label="中药治疗" prop="zyzl">
              <el-radio-group v-model="conditionData.zyzl">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="conditionData.other !== null">
            <el-form-item label="其他" prop="other">
              <!-- <el-radio-group v-model="conditionData.type1">
                <el-radio label="1">是</el-radio>
                <el-radio label="0">否</el-radio>
              </el-radio-group> -->
              <el-input v-model="conditionData.other" placeholder="请输入内容"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="title" v-if="leaveTime && leaveTime.length">出院时间</div>
        <el-row v-if="leaveTime && leaveTime.length">
          <el-col :span="24">
            <el-form-item label="出院时间" prop="leaveTime">
              <el-date-picker v-model="leaveTime" @change="changeDatePicker" type="datetimerange"
                value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
              </el-date-picker>
              <!-- <el-date-picker
                v-model="conditionData.leaveTime"
                type="daterange"
                range-separator="至"
                value-format="yyyy-MM-dd HH:mm:ss"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker> -->
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="conditionSubmit">确 定</el-button>
        <el-button @click="conditionCancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 设置科研路径 -->
    <el-dialog title="设置科研路径" :visible.sync="studyDialog" width="1000px" append-to-body>
      <el-form ref="form" :model="studyData" :rules="studyDataRules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="变量标签" prop="labels">
              <el-cascader v-model="studyData.archivesTagIdList" style="width: 100%" :options="labelOptions"
                :props="props" :show-all-levels="false"></el-cascader>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="studySubmit">确 定</el-button>
        <el-button @click="studyCancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 详情页 -->
    <el-dialog title="课题详情" :visible.sync="detailsDialog" width="1000px" append-to-body>
      <el-form ref="form" :model="detailsData" label-width="120px">
        <div class="title">课题信息</div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="所属项目">
              {{ detailsData.projectName }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="课题名称">
              {{ detailsData.name }}
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="课题描述">
              {{ detailsData.education }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="创建人">
              {{ detailsData.createBy }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="创建时间">
              {{ detailsData.createTime }}
            </el-form-item>
          </el-col>
        </el-row>
        <div class="title" v-if="getGroupShow()">入组条件</div>
        <el-row v-if="detailsData.conditionData">
          <!-- == 空字符 -->
          <el-col :span="12" v-if="detailsData.conditionData.gender !== null">
            <el-form-item label="性别">
              <dict-tag :options="dict.type.sys_user_sex" :value="detailsData.conditionData.gender + ''" />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="detailsData.conditionData.age != null">
            <el-form-item label="年龄段" >
              <span v-if="detailsData.conditionData.age == '1'">0~9岁"</span>
              <span v-else-if="detailsData.conditionData.age == '2'">10~19岁</span>
              <span v-else-if="detailsData.conditionData.age == '3'">20~29岁</span>
              <span v-else-if="detailsData.conditionData.age == '4'">30~39岁</span>
              <span v-else-if="detailsData.conditionData.age == '5'">40~49岁</span>
              <span v-else-if="detailsData.conditionData.age == '6'">50~59岁</span>
              <span v-else-if="detailsData.conditionData.age == '7'">60~69岁</span>
              <span v-else-if="detailsData.conditionData.age == '8'">70~79岁</span>
              <span v-else-if="detailsData.conditionData.age == '9'">80~89岁</span>
              <span v-else-if="detailsData.conditionData.age == '10'">90~99岁</span>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="detailsData.conditionData.education != null">
            <el-form-item label="受教育程度">
              <template v-for="(item, index) in educationOptions">
                <span :key="index" v-if="item.value - 0 == detailsData.conditionData.education">
                  {{ item.label }}
                </span>
              </template>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="detailsData.conditionData.job != null">
            <el-form-item label="职业">
              <template v-for="(item, index) in careerOptions">
                <span :key="index" v-if="item.value - 0 == detailsData.conditionData.job">
                  {{ item.label }}
                </span>
              </template>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="地区">
              <el-cascader disabled v-model="detailsData.conditionData.area" style="width: 100%" :options="areaData"
                :props="areaProps" clearable></el-cascader>
            </el-form-item>
          </el-col> -->
          <el-col :span="24" v-if="detailsData.conditionData.treatmentTypes && detailsData.conditionData.treatmentTypes.length">
            <el-form-item label="治疗类型">
              <template v-for="(item, index) in typesOptions">
                <span :key="index" v-if="isZLLX(item)">
                  {{ item.label }}
                </span>
              </template>
            </el-form-item>
          </el-col>
          <el-col :span="24" v-if="detailsData.conditionData.zdbm && detailsData.conditionData.zdbm.length">
            <el-form-item label="诊断编码">
              <el-select style="width: 100%" disabled v-model="detailsData.conditionData.zdbm" placeholder="请选择诊断编码"
                multiple clearable>
                <el-option label="脑卒中，未特指为出血或梗死" value="I64">
                </el-option>
                <el-option label="入脑前动脉的闭塞或狭窄，未造成脑梗死" value="I65">
                </el-option>
                <el-option label="大脑动脉的闭塞和狭窄，未造成脑梗死" value="I66">
                </el-option>
                <el-option label="其它脑血管病、急性动脉瘤" value="I67">
                </el-option>
                <el-option label="分类于他处的疾病引起的脑血管疾患" value="I68">
                </el-option>
                <el-option label="中高危风险患者预防静脉血栓栓塞" value="I82.900x004">
                </el-option>
                <el-option label="脑梗死" value="I63"> </el-option>
                <el-option label="短暂性脑缺血发作（TIA）" value="G45.900x001">
                </el-option>
                <el-option label="脑内出血" value="I61"> </el-option>
                <el-option label="蛛网膜下腔出血" value="I60"> </el-option>
                <el-option label="大脑静脉血栓形成引起的脑梗死，非生脓性" value="I63.600">
                </el-option>
                <el-option label="化脓性海绵窦血栓形成" value="G08.x00x006">
                </el-option>
                <el-option label="产褥期大脑静脉窦血栓形成" value="O87.301">
                </el-option>
                <el-option label="化脓性乙状窦血栓形成" value="G08.x00x003">
                </el-option>
                <el-option label="化脓性横窦血栓形成" value="G08.x00x009">
                </el-option>
                <el-option label="侧窦栓塞" value="G08.x00x010"> </el-option>
                <el-option label="椎-基底动脉盗血综合征" value="G45.003">
                </el-option>
                <el-option label="锁骨下动脉盗血综合征" value="G45.801">
                </el-option>
                <el-option label="颈内动脉供血不足" value="G45.101">
                </el-option>
                <el-option label="颈动脉闭塞综合征" value="G45.102">
                </el-option>
                <el-option label="脑淀粉样脑血管病（CAA）" value="E85.400x027">
                </el-option>
                <el-option label="脑血管畸形" value="Q28.300x001"> </el-option>
                <el-option label="伴皮层下梗死和白质脑病的常隐性脑动脉病（CARASIL）" value="I67.8">
                </el-option>
                <el-option label="伴皮层下梗死和白质脑病的常染色体显性遗传性脑动脉病(CADASIL)" value="I67.800x012">
                </el-option>
                <el-option label="法布里病（FabryDisease）" value="E75.200x023 E75.205">
                </el-option>
                <el-option label="线粒体脑肌病伴高乳酸血症和卒中样发作综合征（MELAS）" value="G71.300x001">
                </el-option>
                <el-option label="血管性痴呆" value="F01.900"> </el-option>
                <el-option label="皮层下血管性痴呆" value="F01.200">
                </el-option>
                <el-option label="混合型皮层和皮层下血管性痴呆" value="F01.300">
                </el-option>
                <el-option label="血管性痴呆，其他的" value="F01.800">
                </el-option>
                <el-option label="出血性痴呆" value="F01.800x001"> </el-option>
                <el-option label="初发性或维持性睡眠障碍［失眠症］" value="G47.000">
                </el-option>
                <el-option label="日节律性睡眠障碍" value="G47.200x003">
                </el-option>
                <el-option label="睡眠障碍,其他的" value="G47.800"> </el-option>
                <el-option label="睡眠障碍" value="G47.900"> </el-option>
                <el-option label="血管性帕金森综合征" value="G21.400">
                </el-option> </el-select></el-form-item>
          </el-col>
          <el-col :span="24" v-if="detailsData.conditionData.ssbm && detailsData.conditionData.ssbm.length">
            <el-form-item label="手术编码">
              <el-cascader v-model="detailsData.conditionData.ssbm" disabled style="width: 100%" :options="options"
                :props="props" :show-all-levels="false"></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="24" 
            v-if="detailsData.conditionData.jyy || 
            detailsData.conditionData.kny || 
            detailsData.conditionData.jty || 
            detailsData.conditionData.kxxby || 
            detailsData.conditionData.tzy || 
            detailsData.conditionData.kxgjly || 
            detailsData.conditionData.zyzl ||
            detailsData.conditionData.other"
          >
            <el-form-item label="出院带药">
              <!-- 降压药、抗凝药、降糖药、*** -->
              <span v-if="detailsData.conditionData.jyy == 1">降压药、</span>
              <span v-if="detailsData.conditionData.kny == 1">抗凝药、</span>
              <span v-if="detailsData.conditionData.jty == 1">降糖药、</span>
              <span v-if="detailsData.conditionData.kxxby == 1">抗血小板药、</span>
              <span v-if="detailsData.conditionData.tzy == 1">调脂药、</span>
              <span v-if="detailsData.conditionData.kxgjly == 1">抗血管痉挛药、</span>
              <span v-if="detailsData.conditionData.zyzl == 1">中药治疗、</span>
              <span v-if="detailsData.conditionData.other">{{
                detailsData.conditionData.other
              }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="title" v-if="detailsData.tagVoList && detailsData.tagVoList.length">科研路径</div>
        <el-row v-if="detailsData.tagVoList && detailsData.tagVoList.length">
          <el-col :span="24">
            <el-form-item label="科研路径">
              <!-- 筛查-基本信息、筛查-既往病史、筛查-生活方式、*** -->
              <el-cascader disabled v-model="detailsData.tagVoList" style="width: 100%" :options="labelOptions"
                :props="props" :show-all-levels="false"></el-cascader>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-radio-group v-model="patientParam.param.status" @change="changeGroupStaus">
        <el-radio-button :label="0">待入组</el-radio-button>
        <el-radio-button :label="1">已入组</el-radio-button>
      </el-radio-group>

      <el-table v-loading="loading" :data="data1List" style="width: 100%; margin-top: 16px"
        @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" fixed />
        <el-table-column type="index" label="序号" width="55" align="center" fixed />
        <!-- <el-table-column prop="projectName" label="所属项目" width="200">
        </el-table-column> -->
        <el-table-column prop="dah" label="档案号" width="100">
        </el-table-column>
        <el-table-column prop="idcard" label="身份证号" width="180">
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="100">
        </el-table-column>
        <el-table-column prop="gender" label="性别" width="100">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender" />
          </template>
        </el-table-column>
        <el-table-column prop="zyh" label="住院号" width="100">
        </el-table-column>
        <el-table-column prop="zyys" label="住院医师" width="100">
        </el-table-column>
        <el-table-column prop="zllx" label="治疗类型" align="center" width="200">
          <template slot-scope="scope">
            {{scope.row.zllx}}
            <template v-if="scope.row.zllx">
              <el-tag :effect="
                scope.row.zllx.split(',').findIndex((item) => {
                  return item == 'AIS静脉溶栓';
                }) != -1
                  ? 'dark'
                  : 'plain'
              ">
                AIS静脉溶栓
              </el-tag>
              <el-tag :effect="
                scope.row.zllx.split(',').findIndex((item) => {
                  return item == 'AIS介入再通';
                }) != -1
                  ? 'dark'
                  : 'plain'
              ">
                AIS介入再通
              </el-tag>
              <el-tag :effect="
                scope.row.zllx.split(',').findIndex((item) => {
                  return item == '脑出血';
                }) != -1
                  ? 'dark'
                  : 'plain'
              ">
                脑出血
              </el-tag>
              <el-tag :effect="
                scope.row.zllx.split(',').findIndex((item) => {
                  return item == '颅内动脉瘤';
                }) != -1
                  ? 'dark'
                  : 'plain'
              ">
                颅内动脉瘤
              </el-tag>
              <el-tag :effect="
                scope.row.zllx.split(',').findIndex((item) => {
                  return item == 'CES/CAS';
                }) != -1
                  ? 'dark'
                  : 'plain'
              ">
                CES/CAS
              </el-tag>
            </template>
          </template>
        </el-table-column>
        <el-table-column prop="cysj" label="出院时间" width="220">
        </el-table-column>
        <el-table-column prop="deptId" label="所属科室" width="100">
        </el-table-column>
        <el-table-column prop="sjly" label="数据来源" width="100">
        </el-table-column>
        <el-table-column prop="jddw" label="建档单位" width="100">
        </el-table-column>
        <el-table-column prop="jdr" label="建档人" width="100">
        </el-table-column>
        <el-table-column prop="jdsj" label="建档时间" width="100">
        </el-table-column>
        <el-table-column prop="shr" label="审核人" width="100">
        </el-table-column>
        <el-table-column prop="shsj" label="审核时间" width="100">
        </el-table-column>
        <el-table-column prop="dazt" label="档案状态" width="100">
          <template slot-scope="scope">
            <div v-if="scope.row.dazt == '0'">未提交</div>
            <div v-else-if="scope.row.dazt == '1'">已提交</div>
            <div v-else-if="scope.row.dazt == '2'">已审核</div>
            <div v-else-if="scope.row.dazt == '3'">已驳回</div>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right" width="180">
          <template slot-scope="scope">
            <!-- <i class="el-icon-star-on" style="color: #FFBE00"></i> -->
            <el-button size="mini" type="text" icon="el-icon-star-on" style="color: #c0c4cc"
              v-if="patientParam.param.status == 1">收藏</el-button>
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleOpenDetails(scope.row)"
              v-hasPermi="['system:dept:edit']">详情</el-button>
            <el-button size="mini" type="text" icon="el-icon-plus" @click="enrollment(scope.row)"
              v-hasPermi="['system:dept:edit']" v-if="patientParam.param.status == 0">入组</el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" style="color: red" @click="goOutGroup(scope.row)"
              v-hasPermi="['system:dept:edit']" v-if="patientParam.param.status == 1">出组</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="patientTotal > 0" :total="patientTotal" :page.sync="patientParam.pageNum"
        :limit.sync="patientParam.pageSize" @pagination="getPatientLists" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="detailsSubmit">确 定</el-button>
        <el-button @click="detailsCancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import {
    getListTopic,
    changeTopic,
    delTopic,
    queryEntryConditionsResult,
    addEntryConditionsResult,
    queryResearchPath,
    addResearchPath,
    queryDetailByTopic,
    addGroup,
    delGroup,
  } from "@/api/topic/index";
  import {
    getListCms
  } from "@/api/business/cms";
  import {
    getListCode
  } from "@/api/business/definition";
  import {
    getAreas
  } from "@/api/menu";
  import {
    listProject,
  } from "@/api/data/topic";
  export default {
    dicts: ["sys_user_sex"],
    data() {
      return {
        // 遮罩层
        loading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        selectionData: [],
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          param: {
            education: "",
            id: null,
            name: "",
            projectId: "",
          },
        },
        tagList: [],
        dataList: [],
        total: 0,
        title: "",
        addDialog: false,
        addForm: {
          projectId: null,
          name: null,
          education: null,
        },
        topicRules: {
          projectId: [{
            required: true,
            message: "请选择所属项目",
            trigger: "blur"
          }, ],
          name: [{
            required: true,
            message: "请输入课题名称",
            trigger: "blur"
          }],
        },
        conditionDialog: false, // 入组条件弹框
        leaveTime: [],
        conditionData: {
          treatmentTypes: [],
        },
        conditionDataRules: {},
        props: {
          multiple: true,
          emitPath: false
        },
        options: [{
            value: "01",
            label: "急性脑梗死介入再通",
            children: [{
                value: "39.74",
                label: "头和颈部血管梗阻的血管内去除术",
              },
              {
                value: "39.7400x002",
                label: "经皮颅内动脉取栓术",
              },
              {
                value: "39.7400x004",
                label: "经皮颈动脉取栓术",
              },
              {
                value: "39.7401",
                label: "经导管颅内血管血栓去除术",
              },
              {
                value: "39.7402",
                label: "经导管入脑前血管血栓去除术",
              },
              {
                value: "99.1008",
                label: "脑动脉内溶栓术",
              },
            ],
          },
          {
            value: "02",
            label: "颈动脉支架",
            children: [{
                value: "00.6100x008",
                label: "经皮颈总动脉球囊扩张成形术",
              },
              {
                value: "0.6101",
                label: "经皮颈动脉球囊扩张成形术",
              },
              {
                value: "0.63",
                label: "颈动脉支架经皮置入术",
              },
              {
                value: "00.6300x005",
                label: "经皮颈动脉远端保护装置置入术",
              },
              {
                value: "00.6300x006",
                label: "经皮颈动脉覆膜支架置入术",
              },
              {
                value: "00.6300x007",
                label: "经皮颈动脉药物洗脱支架置入术",
              },
              {
                value: "0.6301",
                label: "脑保护伞下颈动脉支架置入术",
              },
            ],
          },
          {
            value: "03",
            label: "颈动脉内膜剥脱",
            children: [{
                value: "38.12",
                label: "头和颈部其他血管内膜切除术",
              },
              {
                value: "38.1200x003",
                label: "颈动脉内膜剥脱术",
              },
              {
                value: "38.1201",
                label: "颈动脉内膜切除术",
              },
              {
                value: "38.1202",
                label: "颈动脉内膜切除伴补片修补术",
              },
            ],
          },
          {
            value: "04",
            label: "脑出血，开颅血肿清除",
            children: [{
                value: "01.3900x009",
                label: "脑内血肿清除术",
              },
              {
                value: "01.3900x012",
                label: "经外侧裂脑内血肿清除术",
              },
              {
                value: "1.3904",
                label: "经颞叶脑血肿清除术",
              },
              {
                value: "1.391",
                label: "脑血肿切开引流术",
              },
              {
                value: "1.2408",
                label: "颅内血肿清除术",
              },
              {
                value: "1.3906",
                label: "内镜下脑血肿引流术",
              },
            ],
          },
          {
            value: "05",
            label: "脑出血，穿刺引流",
            children: [{
                value: "01.3900x013",
                label: "立体定向颅内血肿穿刺引流术",
              },
              {
                value: "1.3905",
                label: "脑立体定向血肿碎吸术",
              },
              {
                value: "01.3900x003",
                label: "颅内血肿硬通道穿刺引流术",
              },
            ],
          },
          {
            value: "06",
            label: "动脉瘤，开颅",
            children: [{
                value: "39.51",
                label: "钳夹动脉瘤",
              },
              {
                value: "39.5100x004",
                label: "内窥镜下脑动脉瘤夹闭术",
              },
              {
                value: "39.5100x007",
                label: "脑动脉瘤夹闭术",
              },
              {
                value: "39.5101",
                label: "颈动脉瘤夹闭术",
              },
              {
                value: "39.5102",
                label: "大脑前动脉瘤夹闭术",
              },
              {
                value: "39.5103",
                label: "大脑中动脉瘤夹闭术",
              },
              {
                value: "39.5104",
                label: "后交通动脉瘤夹闭术",
              },
              {
                value: "39.5105",
                label: "基底动脉瘤夹闭术",
              },
              {
                value: "39.5106",
                label: "椎动脉瘤夹闭术",
              },
              {
                value: "39.5107",
                label: "前交通动脉瘤夹闭术",
              },
              {
                value: "39.5108",
                label: "小脑上动脉瘤夹闭术",
              },
              {
                value: "38.61",
                label: "颅内血管其他切除术",
              },
              {
                value: "38.6100x002",
                label: "颅内动脉瘤切除术",
              },
              {
                value: "39.5201",
                label: "动脉瘤包裹术",
              },
            ],
          },
          {
            value: "07",
            label: "动脉瘤，栓塞",
            children: [{
                value: "39.72",
                label: "头和颈部血管内修补或闭合",
              },
              {
                value: "39.7200x004",
                label: "颈内动脉栓塞术",
              },
              {
                value: "39.7200x006",
                label: "大脑中动脉（MCA分叉部）动脉瘤栓塞术（AN）",
              },
              {
                value: "39.7201",
                label: "头部血管内修补或闭合术",
              },
              {
                value: "39.7203",
                label: "经导管颅内动脉瘤栓塞术",
              },
              {
                value: "39.7204",
                label: "经导管颅内动脉瘤弹簧圈栓塞术",
              },
              {
                value: "39.7205",
                label: "经导管颅内动脉瘤支架辅助栓塞术",
              },
              {
                value: "39.7206",
                label: "经导管颈动脉瘤栓塞术",
              },
              {
                value: "39.7207",
                label: "经导管颈动脉瘤弹簧圈栓塞术",
              },
              {
                value: "39.7208",
                label: "经导管颈动脉瘤支架辅助栓塞术",
              },
              {
                value: "39.7209",
                label: "经导管颅内血管栓塞术",
              },
              {
                value: "39.721",
                label: "经导管颅内血管弹簧圈栓塞术",
              },
              {
                value: "39.75",
                label: "头、颈部血管内裸弹簧圈栓塞或闭合",
              },
              {
                value: "39.7500x001",
                label: "经导管颅内动脉瘤裸弹簧圈栓塞术",
              },
              {
                value: "39.7500x002",
                label: "经导管颈动脉瘤裸弹簧圈栓塞术",
              },
              {
                value: "39.7500x003",
                label: "经导管颈部血管裸弹簧圈栓塞术",
              },
              {
                value: "39.7500x004",
                label: "经导管椎动脉裸弹簧圈栓塞术",
              },
              {
                value: "39.7501",
                label: "经导管颅内血管裸弹簧圈栓塞术",
              },
              {
                value: "39.7502",
                label: "经导管入脑前血管裸弹簧圈栓塞术",
              },
              {
                value: "39.76",
                label: "头、颈部血管生物活性弹簧圈血管内栓塞或闭合",
              },
              {
                value: "39.7600x001",
                label: "经导管颅内血管生物活性弹簧圈栓塞术",
              },
              {
                value: "39.7601",
                label: "经导管颅内动脉瘤生物活性弹簧圈栓塞术",
              },
              {
                value: "39.7602",
                label: "经导管入脑前血管生物活性弹簧圈栓塞术",
              },
              {
                value: "39.7603",
                label: "经导管颈动脉瘤生物活性弹簧圈栓塞术",
              },
              {
                value: "39.7604",
                label: "经导管颈部血管生物活性弹簧圈栓塞术",
              },
              {
                value: "39.7605",
                label: "经导管椎动脉生物活性弹簧圈栓塞术",
              },
            ],
          },
        ],
        studyDialog: false,
        studyData: {
          archivesTagIdList: [],
        },
        studyDataRules: {},
        labelOptions: [],
        detailsData: {},
        detailsDialog: false,
        patientTotal: 0,
        patientParam: {
          pageNum: 1,
          pageSize: 10,
          param: {
            status: 0,
            topicId: "",
          },
          sort: "",
        },
        data1List: [],
        educationOptions: {},
        careerOptions: {},
        typesOptions: {},
        areaData: [],
        areaProps: {
          label: "name",
          value: "id",
          children: "child",
          multiple: false,
          emitPath: false,
        },
        projectList: [],
      };
    },
    async created() {
      this.getList();
      this.labelOptions = [];
      this.getAreaData();
      this.getProjectList();
      await this.getArchivesMenu("0");
      await this.getArchivesMenu("1");
      await this.getArchivesMenu("2");
      await this.getArchivesMenu("3");
      await this.getVariable("FILES-EDUC");
      await this.getVariable("FILES-CAREER");
      await this.getVariable("ZLLX-TYPE");
    },
    computed: {

    },
    methods: {
      getGroupShow() {
        if (!this.detailsData.conditionData) {
          return false;
        }
        let conditionData = this.detailsData.conditionData;
        if (
          conditionData.gender !== null ||
          conditionData.age != null ||
          conditionData.education != null ||
          conditionData.job != null ||
          (conditionData.treatmentTypes && conditionData.treatmentTypes.length) ||
          (conditionData.zdbm && conditionData.zdbm.length) ||
          (conditionData.ssbm && conditionData.ssbm.length) ||
          conditionData.jyy ||
          conditionData.kny ||
          conditionData.jty ||
          conditionData.kxxby ||
          conditionData.tzy ||
          conditionData.kxgjly ||
          conditionData.zyzl ||
          conditionData.other
        ) {
          return true;
        }
        return false;
      },
      isZLLX(item) {
        let a = this.detailsData.conditionData.treatmentTypes
        if (a) {
          let result = a.find((data) => {
            return item.value - 0 == data;
          })
                 
          return result
        } else {
          return false
        }
      },
      changeGroupStaus(value) {
        this.patientParam.param.status = value
        queryDetailByTopic(this.patientParam).then((res) => {
          if (res.code == 200) {
            this.patientTotal = res.data.total - 0;
            this.data1List = res.data.list;
          }
        });
      },
      changeDatePicker(value) {
        console.log(value, 'changeDatePicker')
        this.conditionData.startTime = value[0]
        this.conditionData.endTime = value[1]
      },
      // 获取数据列表
      getProjectList() {
        const param = {
          pageNum: 1,
          pageSize: 999,
          param: {
            name: "",
          },
        };
        listProject(param).then((response) => {
          this.projectList = [...response.data.list];
        });
      },
      getAreaData() {
        const param = {
          pageNum: 0,
          pageSize: 0,
          param: {
            id: 0,
          },
        };
        getAreas(param).then((res) => {
          this.areaData = [...res.data];
        });
      },
      // 根据code查询变量(入组条件)
      async getVariable(code) {
        const queryParams = {
          pageNum: 1,
          pageSize: 1,
          param: {
            code,
          },
        };
        await getListCode(queryParams).then((res) => {
          if (res.data.total) {
            // if (code == "") {
            //   // 年龄段
            //   this.ageOptions = { ...res.data.list[0] };
            // } else
            const options = JSON.parse(res.data.list[0].options);
            let arr = [];
            for (let key in options) {
              const obj = {
                value: key,
                label: options[key],
              };
              arr.push(obj);
            }
            if (code == "FILES-EDUC") {
              // 受教育程度
              this.educationOptions = [...arr];
            } else if (code == "FILES-CAREER") {
              // 职业
              this.careerOptions = [...arr];
            } else if (code == "ZLLX-TYPE") {
              // 治疗类型
              this.typesOptions = [...arr];
            }
          }
        });
      },
      // 查询档案菜单
      async getArchivesMenu(type) {
        const param = {
          pageNum: 1,
          pageSize: 99,
          param: {
            name: null,
            type,
          },
        };
        await getListCms(param).then((res) => {
          const {
            data
          } = res;
          let obj = {};
          obj.value = type - 10;
          if (type == "0") {
            obj.label = "筛查";
          } else if (type == "1") {
            obj.label = "急救";
          } else if (type == "2") {
            obj.label = "治疗";
          } else if (type == "3") {
            obj.label = "康复";
          }
          if (data.total > 0) {
            obj.children = data.list.map((item) => {
              return {
                value: item.id,
                label: item.name,
              };
            });
          } else {
            obj.children = [];
          }
          this.labelOptions.push(obj);
          // this.total = data.total;
          // this.loading = false;
        });
      },
      // 导出数据
      // downloadData() {
      //   const that = this;
      //   this.$modal
      //     .confirm("是否确认导出当前查询条件下的数据？")
      //     .then(function () {
      //       // 导出
      //       const params = that.queryParams;
      //       return that.download(
      //         exportData,
      //         { ...params.param },
      //         `策略_${new Date().getTime()}.xlsx`
      //       );
      //     })
      //     .then((res) => {
      //       that.$message.success("导出成功");
      //     })
      //     .catch(() => {});
      // },
      // 搜索事件
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      // 重置事件
      resetQuery() {
        this.dataList = [];
        this.total = 0;
        this.queryParams.pageNum = 1;
        this.queryParams.pageSize = 10;
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 获取数据列表
      getList() {
        this.loading = true;
        const param = {
          ...this.queryParams
        };
        getListTopic(param).then((response) => {
          this.dataList = response.data.list;
          this.total = response.data.total;
          this.loading = false;
        });
      },
      // 列表选中事件
      handleSelectionChange(selection) {
        this.ids = selection.map((item) => item.id);
        this.selectionData = [...selection];
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
      // 新增变量
      handleAdd() {
        this.title = "新增课题";
        this.addDialog = true;
      },
      // 新增/修改弹框提交事件
      async submitForm() {
        this.$refs["topic"].validate((valid) => {
          if (valid) {
            const param = {
              ...this.addForm
            };
            changeTopic(param).then((res) => {
              if (param.id) {
                this.$message.success("修改成功");
              } else {
                this.$message.success("新增成功");
              }
              this.getList();
              this.addDialog = false;
              this.addForm = {};
            });
          }
        });
      },
      // 新增/修改弹框取消事件
      cancel() {
        this.addForm = {
          projectId: "",
          name: "",
          describe: "",
        };
        this.resetForm("form");
        this.addDialog = false;
      },
      // 修改变量
      handleEdit(row) {
        this.title = "修改课题";
        const data = row.name ? row : this.selectionData[0];
        this.addForm = {
          ...data,
        };
        this.addDialog = true;
      },
      // 删除
      handleDelete(row) {
        const idList = row.id ? [row.id] : [...this.ids];
        this.$modal
          .confirm("是否确认删除当前选择的课题数据？")
          .then(function() {
            // 删除
            return delTopic({
              idList
            });
          })
          .then(() => {
            this.$message.success("删除成功");
            this.handleQuery();
          })
          .catch(() => {});
      },
      // 查看详情
      handleDetails(row) {
        this.detailsData = row;
        const topicId = row.id;
        console.log(topicId, 'topicId')
        queryEntryConditionsResult({
          topicId
        }).then((res) => {
          const {
            data,
            code
          } = res;
          if (code == 200) {
            if (data.treatmentType) {
              data.treatmentTypes = (data.treatmentType + "").split(",");
            }
            if (data.ssbm) {
              data.ssbm = data.ssbm.split(",");
            }
            if (data.zdbm) {
              data.zdbm = data.zdbm.split(",");
            }
            if (data.startTime) {
              this.leaveTime[0] = data.startTime
            }
            if (data.endTime) {
              this.leaveTime[1] = data.endTime
            }
            this.detailsData.conditionData = {
              ...data,
              topicId
            };
            queryResearchPath({
              topicId
            }).then((res) => {
              let data = res.data[0]
              if (data && data.tagVoList.length > 0) {
                let archivesTagIdList = data.tagVoList.map((item) => {
                  return item.archivesTagId;
                })
                this.studyData.archivesTagIdList = archivesTagIdList
                this.studyData.topicId = topicId
                this.detailsData.tagVoList = archivesTagIdList
              }
              this.getPatientList(topicId);
              this.detailsDialog = true;
            });
          }
        });
      },
      getPatientLists() {
        this.getPatientList(this.detailsData.id);
      },
      getPatientList(topicId) {
        this.patientParam.param.topicId = topicId || this.detailsData.id;
        queryDetailByTopic(this.patientParam).then((res) => {
          if (res.code == 200) {
            this.patientTotal = res.data.total - 0;
            this.data1List = res.data.list;
          }
        });
      },
      detailsSubmit() {
        this.detailsDialog = false;
      },
      detailsCancel() {
        this.detailsDialog = false;
      },
      // 设置入组条件
      handleCondition(row) {
        this.leaveTime = []
        const topicId = row.id;
        queryEntryConditionsResult({
          topicId
        }).then((res) => {
          const {
            data
          } = res;
          if (data.treatmentType) {
            data.treatmentTypes = (data.treatmentType + "").split(",");
          }
          if (data.ssbm) {
            data.ssbm = data.ssbm.split(",");
          }
          if (data.zdbm) {
            data.zdbm = data.zdbm.split(",");
          }
          if (data.startTime) {
            this.leaveTime[0] = data.startTime
          }
          if (data.endTime) {
            this.leaveTime[1] = data.endTime
          }
          this.conditionData = {
            ...data,
            topicId,
          };
          this.conditionDialog = true;
        });
      },
      // 确认设置入组条件
      conditionSubmit() {
        const param = Object.assign({}, this.conditionData)
        if (param.treatmentTypes && param.treatmentTypes.length > 0) {
          param.treatmentType = param.treatmentTypes.join();
        }
        if (param.ssbm && param.ssbm.length > 0) {
          param.ssbm = param.ssbm.join();
        } else {
          param.ssbm = ''
        }
        if (param.zdbm && param.zdbm.length > 0) {
          param.zdbm = param.zdbm.join();
        } else {
          param.zdbm = ''
        }
        delete param.treatmentTypes
        addEntryConditionsResult(param).then((res) => {
          this.$message.success("入组条件设置成功");
          this.getList();
          this.conditionDialog = false;
          this.conditionData = {};
        });
      },
      // 取消设置入组条件
      conditionCancel() {
        this.conditionDialog = false;
        this.conditionData = {};
      },
      // 设置科研路径
      handleStudy(row) {
        const topicId = row.id;
        queryResearchPath({
          topicId
        }).then((res) => {
          this.studyData = {
            archivesTagIdList: res.data[0] ?
              res.data[0].tagVoList.map((item) => {
                return item.archivesTagId;
              }) : [],
            topicId,
          };
          this.studyDialog = true;
        });
      },
      // 确认设置科研路径
      studySubmit() {
        const param = {
          ...this.studyData
        };
        addResearchPath(param).then((res) => {
          this.$message.success("科研路径设置成功");
          this.getList();
          this.studyDialog = false;
          this.studyData = {};
        });
      },
      // 取消设置科研路径
      studyCancel() {
        this.studyDialog = false;
        this.studyData = {};
      },
      // 档案详情
      handleOpenDetails(row) {
        this.$message.success("根据档案类型，跳转到当前档案的详情页");
      },
      // 入组
      enrollment(row) {
        // const idList = row.id ? [row.id] : [...this.ids];
        this.$modal.confirm("是否确认将当前数据移入？").then(() => {
          // this.$message.success("入组成功");
          const param = {
            topicId: this.detailsData.id,
            patientId: row.id,
          };
          addGroup(param).then((res) => {
            this.$message.success("入组成功");
            this.getPatientList(this.detailsData.id);
          });
          // return deleteFlupStrategy({ idList });
        });
        // .then(() => {
        //   this.$message.success("删除成功");
        //   this.handleQuery();
        // })
        // .catch(() => {});
      },
      // 出组
      goOutGroup(row) {
        // const idList = row.id ? [row.id] : [...this.ids];
        this.$modal.confirm("是否确认将当前数据移出？").then(() => {
          const param = {
            topicId: this.detailsData.id,
            patientId: row.id,
          };
          delGroup(param).then((res) => {
            this.$message.success("出组成功");
            this.getPatientList(this.detailsData.id);
          });
          // return deleteFlupStrategy({ idList });
        });
        // .then(() => {
        //   this.$message.success("删除成功");
        //   this.handleQuery();
        // })
        // .catch(() => {});
      },
    },
  };
</script>
<style lang="scss">
  .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .row-1 {
    width: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .row-3 {
    width: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .title {
    font-size: 20px;
    color: #333;
    font-weight: bold;
  }
</style>
